package com.nageoffer.jobtrain.projects.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nageoffer.jobtrain.common.web.result.Result;
import com.nageoffer.jobtrain.common.web.result.Results;
import com.nageoffer.jobtrain.projects.dto.req.MessagePageListReqDTO;
import com.nageoffer.jobtrain.projects.dto.resp.MessagePageListRespDTO;
import com.nageoffer.jobtrain.projects.service.MessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统消息控制层
 * author：唐晨
 */
@RestController
@RequiredArgsConstructor
public class MessageController {
    private final MessageService messageService;

    /**
     * 获取系统消息记录 -分页
     */
    @PostMapping("/api/job-train/project/message/page-list")
    public Result<IPage<MessagePageListRespDTO>> messagePageList(@RequestBody MessagePageListReqDTO requestParam) {
        return Results.success(messageService.messagePageList(requestParam));
    }

    /**
     * 系统消息删除功能
     */
    @DeleteMapping("/api/job-train/project/message/delete")
    public Result<Void> deleteMessage(@RequestParam("messageId") Long messageId) {
        messageService.deleteMessage(messageId);
        return Results.success();
    }
}
